package com.czxy.service.Impl;

import com.czxy.dao.CommodityImgMapper;
import com.czxy.domain.CommodityImg;
import com.czxy.service.CommodityImgService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class CommodityImgServiceImpl implements CommodityImgService {

    @Resource
    private CommodityImgMapper commodityImgMapper;

    @Override
    public void insertImgs(List<CommodityImg> commodityImgList) {
        for (CommodityImg commodityImg : commodityImgList) {
            commodityImgMapper.insert(commodityImg);
        }
    }

    @Override
    public List<CommodityImg> selectByCommodityId(String CommodityId) {
        Example example = new Example(CommodityImg.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("commodityId", CommodityId);
        return commodityImgMapper.selectByExample(example);
    }

}
